<?php

// no direct access
defined('_JEXEC') or die('Restricted access');

// Variables
$albumTitle = $album->title;
$bordercolor = $this->params->get('bordercolor');
$bordersize = $this->params->get('bordersize');
$instant = $this->params->get('picasaInstantAlbumEnabled');
$fontcolor = $this->params->get('fontcolor');
$username = $this->params->get('picasaUsername');
$albumlistsize = sizeof($this->albumsList);
$cellspace = $this->params->get('CellSpacing');
$albumeffect = $this->params->get('picasaInstantAlbumEnabled');
$maxrow = $this->params->get('picasaMaxPhotosPerRow');
// Check parameter
if ($maxrow == 0) {
	// Put debug message in HTML page (in HTML comment)
	echo '<!- P2G debug on line '.__LINE__ .' ->';
	// End set a defaulr value
	$maxrow = 1;
}
$templatestyle = $this->params->get('usetemplatestyle');
$fontsize = $this->params->get('fontsize');
$title = $this->params->get('picasatitle');
$thumbsize = $this->params->get('albumThumbSize');
$showintro = $this->params->get('introtekst');
$albumid = $this->params->get('picasaalbumid');
$hidetitle = $this->params->get('hidetitle');
$menus = &JSite::getMenu();
$menu  = $menus->getActive();
$itemid = $menu->id;

JHTML::_('behavior.mootools');

if ( $this->params->def( 'show_page_title', 1 ) ) {
	echo '<div class="componentheading'.$this->params->get( 'pageclass_sfx' ).'">'. $this->params->get('page_title'). '</div>';
}

if ($hidetitle == "1") {
echo "<h1>" . $title  . "</h1>";
}
if ($showintro == "0") {
echo JText::_('P2G_THEREARE') ."<strong> " . $albumlistsize . "</strong>" . " " . JText::_('P2G_albums_present') . " " . "<strong>" . $username . "</strong><br /><br />";
}

if ($instant != '0'){
$loadScript = "<script type='text/javascript' src='" . $this->baseurl . "/components/com_picasa2gallery/libraries/thumbeffects/".$albumeffect."/".$albumeffect.".js'></script>";
$mainframe->addCustomHeadTag($loadScript);
}

//echo "<p align='center'>";

echo "<div align='center'><table cellspacing='".$cellspace."'>";

for ($i = 0; $i < sizeof($this->albumsList); $i++){
	$album = $this->albumsList[$i];
	if ($i % $maxrow == 0) echo "<tr valign=\"middle\">";
	echo "<td align=\"center\">";
	$link = JRoute::_('index.php?option=com_picasa2gallery&view=album&Itemid=' . $itemid . '&album=' .  $album['albumID'] . '&page=1');
	if ( $templatestyle == 1) {
		echo "<a style='color:".$fontcolor.";text-decoration: none;font-size:".$fontsize."px'";
	} else {
		echo "<a";
	}
	echo " href=\"" . $link . "\">";
	echo "<img ";
	if ($instant == '0') {
		echo "style='border:".$bordersize."px solid ".$bordercolor.";cursor:pointer' src='".$album['thumbURL']."' width='" .$thumbsize. "' alt='' /><br />";
	} else {
		echo "style='cursor:pointer' class='".$instant." '";
		echo "' src='".$album['thumbURL']."' width='" .$thumbsize. "' alt='' /><br />";
	}
	echo $album['albumTitle'];
	echo "</a>";
    echo "</td>";
	if ( (($i + $maxrow + 1) % $maxrow) == 0) echo "</tr>";
}
if ( (($i + $maxrow) % $maxrow) != 0) echo "</tr>";
echo "</table></div>";

// ************************ Footer text *********************************
if ($this->params->get('showfooter') == '0') {
  echo "<br /><center>" . $this->params->get('footertext') . "</center>";
}

?>